#include <gtest/gtest.h>

using namespace ::std;

class Solution {
public:
    int climbStairs(int n);
};

int Solution::climbStairs(int n) {
    int cnt_1 = 1, cnt_2 = 2, cnt = n;
    for(int i = 3; i <= n; ++i) {
        cnt = cnt_1 + cnt_2;
        cnt_1 = cnt_2;
        cnt_2 = cnt;
    }
    return cnt;
}

// int Solution::climbStairs(int n) {
//     int dp[3] = {1, 2, n};
//     for(int i = 3; i <= n; ++i) {
//         dp[2] = dp[0] + dp[1];
//         dp[0] = dp[1];
//         dp[1] = dp[2];
//     }
//     return dp[n < 3 ? n - 1 : 2];
// }

class ClimbStairsCheck : public ::testing::Test {
public:
	class Solution solution;
};

TEST_F(ClimbStairsCheck, testClimbStairs_1) {
    EXPECT_TRUE(2 == solution.climbStairs(2));
}

TEST_F(ClimbStairsCheck, testClimbStairs_2) {
    EXPECT_TRUE(10946 == solution.climbStairs(20));
}

TEST_F(ClimbStairsCheck, testClimbStairs_3) {
    EXPECT_TRUE(1346269 == solution.climbStairs(30));
}

int main() {
	::testing::InitGoogleTest();
	return RUN_ALL_TESTS();
}
